package com.biwin.common.app.basic;

import cn.hutool.core.collection.CollUtil;
import com.biwin.common.api.constant.BwSystemConstant;
import com.biwin.common.api.dto.IBwDto;
import com.biwin.common.app.enums.MatchTypeEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @author biwin
 * @since
 */
public class BwCondition implements IBwDto {

    /**
     * Relationship between multiple conditions
     * default value :  MatchType.And
     */
    private MatchTypeEnum relation = MatchTypeEnum.AND;

    /**
     * The relationship between the PropertyName and the PropertyValue in the current condition
     * default value : MatchType.EQ
     */
    private MatchTypeEnum matchType = MatchTypeEnum.EQ;

    /**
     * condition query name
     */
    private String propertyName;

    /**
     * condition query value
     * default
     */
    private Object propertyValue;

    /**
     * condition query value with MatchType.BETWEEN or MatchType.BETWEEN_NONE
     */
    private Object betweenValue;

    public BwCondition() {
    }

    public BwCondition(String propertyName, Object propertyValue) {
        this.propertyName = propertyName;
        setPropertyValue(propertyValue);
    }

    public static BwCondition newEffectCondition() {
        return new BwCondition(BwSystemConstant.DELETED, false);
    }

    public MatchTypeEnum getRelation() {
        return relation;
    }

    public void setRelation(MatchTypeEnum relation) {
        this.relation = relation;
    }

    public MatchTypeEnum getMatchType() {
        return matchType;
    }

    public void setMatchType(MatchTypeEnum matchType) {
        this.matchType = matchType;
    }

    public String getPropertyName() {
        return propertyName;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    public Object getPropertyValue() {
        return propertyValue;
    }

    public void setPropertyValue(Object propertyValue) {
        this.propertyValue = propertyValue;
        if (propertyValue instanceof List) {
            List propertyValueList = new ArrayList();
            if (CollUtil.isEmpty(propertyValueList)) {

            }
        }
    }

    public Object getBetweenValue() {
        return betweenValue;
    }

    public void setBetweenValue(Object betweenValue) {
        this.betweenValue = betweenValue;
    }
}
